package cn.gailvlun.gll.presentation.hotel.compose

import android.databinding.DataBindingUtil
import android.view.Gravity
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.PopupWindow
import cn.gailvlun.gll.R
import cn.gailvlun.gll.databinding.PopupComposePanelBinding
import cn.gailvlun.gll.presentation.base.BaseActivity
import cn.gailvlun.gll.presentation.hotel.day.HotelSpeakActivity
import cn.gailvlun.gll.presentation.hotel.day.HotelWriteActivity


class ComposePanelWindow(val activity: BaseActivity)
    : PopupWindow(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT) {
    val attachedView: ViewGroup by lazy {
        activity.findViewById<ViewGroup>(android.R.id.content)
    }
    val popupComposePanelBinding: PopupComposePanelBinding by lazy {
        DataBindingUtil.inflate<PopupComposePanelBinding>(LayoutInflater.from(activity), R.layout.popup__compose_panel, null, false)
    }

    init {
        animationStyle = R.style.BaseDialog_Bottom_UP
        popupComposePanelBinding.presenter = ComposePresenter()
        contentView = popupComposePanelBinding.root
    }

    fun show() {

        showAtLocation(attachedView, Gravity.BOTTOM, 0, 0)
    }

    inner class ComposePresenter {
        fun onSpeak() {
            HotelSpeakActivity.openActivity(activity)
        }

        fun onWrite() {
            HotelWriteActivity.openActivity(activity)
        }
    }

}